package com.application.lucky.request.nav;

import android.text.TextUtils;
import android.util.Log;

import com.application.lucky.Lucky;
import com.application.lucky.bean.sqliteBean.HostUrlData;
import com.application.lucky.config.Config;
import com.application.lucky.gen.HostUrlDataDao;


import java.util.HashMap;
import java.util.Map;

/**
 * @author lixiaoyu
 * @version v1.0
 * @description
 * @since 2017/10/23
 */

public class UrlManager {

    private static Object lock = new Object();

    public static Map<String, String> urlMap = new HashMap<>();

    public static String getUrl(String key) {
        synchronized (lock) {
            boolean containsKey = urlMap.containsKey(key);
            if (containsKey) {
                return urlMap.get(key);
            }
            return null;
        }
    }

    public static void put(Map<String, String> navs) {
        synchronized (lock) {
            urlMap.putAll(navs);
        }
    }

    public static String getHeadPic(String s) {
        if (TextUtils.isEmpty(s)) {
            return
                    Config.HIDE_PIC;
        }
        String url = getUrl(UrlList.head_pic);
//        Log.i("askjhaslkdh", url);
        return url + s;
    }

    public static String getInviteurl() {
        String url = getUrl(UrlList.invite);
        return url;
    }

    public static String getws() {
        String ws_url = getUrl("ws_url");
        if (ws_url != null) {
            if (ws_url.startsWith("http")) {
                return ws_url.replace("http", "ws");
            }
        }
        return null;
    }
}
